package git.soulbgm.controller;

import git.soulbgm.common.pojo.ResultData;
import git.soulbgm.common.pojo.ReturnCode;
import git.soulbgm.pojo.ImUser;
import git.soulbgm.service.FriendListingService;
import git.soulbgm.service.ImUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.HashMap;

/**
 * @author 贺瑞杰
 * @version V1.0
 * @date 2019-04-16 13:58
 * @description
 */
@RestController
public class ImUserController {

    @Autowired
    private ImUserService service;

    @RequestMapping("login")
    public ResultData<HashMap<String, Object>> login(HttpSession session, String username, String password) {
        HashMap<String, Object> map = service.login(username, password);
        session.setAttribute("userInfo", map);
        return ResultData.getResultData(ReturnCode.SUCCESS, map);
    }

    @RequestMapping("register")
    public ResultData<ImUser> register(ImUser user) {
        return ResultData.getResultData(ReturnCode.SUCCESS, service.register(user));
    }

}
